<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Client Account Detail Form</title>
<link rel="stylesheet" type="text/css" href="css/loginstyle.css"/>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/ddaccordion.js"></script>
<link rel="stylesheet" type="text/css" href="css/popup_css.css" />

<script type="text/javascript">
ddaccordion.init({
	headerclass: "submenuheader", 
	contentclass: "submenu", 
	revealtype: "click", 
	mouseoverdelay: 200, 
	collapseprev: true,
	defaultexpanded: [], 
	onemustopen: false, 
	animatedefault: false, 
	persiststate: true, 
	toggleclass: ["", ""], 
	togglehtml: ["suffix", "<img src='images/plus.gif' class='statusicon' />", "<img src='images/minus.gif' class='statusicon' />"],
	animatespeed: "fast",
	oninit:function(headers, expandedindices){ 
	},
	onopenclose:function(header, index, state, isuseractivated){ 
	}
});

$(document).ready(function() {
	
	
	$('#close').click(function(){
	    parent.history.back();
	    return false;
	});
	
	$.ajax({
		url : './broker/getList',
		dataType: "json",
		contentType: 'application/json',			  
		  
		success : function(jsonData) {
			var select = document.getElementById("brokerId");
			var option = document.createElement("option");
			select.appendChild(option);
			for(var a in jsonData){
			
					var option = document.createElement("option");
        	        option.value =jsonData[a]["brokerId"]; ;
        	        option.textContent = jsonData[a]["brokerId"];;
        	        select.appendChild(option);
			
			}		
		}
	});
	
	 $('#brokerId').change(function(event) {  
	    	
		    var brokerId=$("select#brokerId").val();
		    $.ajax({
		    	type:"POST",
				url : './broker/updateMngUser',
				dataType: "json",
				contentType: 'application/json',			  
				 data:brokerId, 
				success : function(jsonData) {
						for(var a in jsonData)
				{
					document.getElementById("bname").value=jsonData[a]["bname"];
					document.getElementById("accno").value=jsonData[a]["accno"];
					document.getElementById("brokage").value=jsonData[a]["brokage"];
					document.getElementById("cashl").value=jsonData[a]["cashl"];
					document.getElementById("marginl").value=jsonData[a]["marginl"];
					document.getElementById("ifsc").value=jsonData[a]["ifsc"];
					document.getElementById("creditamt").value=jsonData[a]["creditamt"];
					document.getElementById("debitamt").value=jsonData[a]["debitamt"];
					document.getElementById("billno").value=jsonData[a]["billno"];
					document.getElementById("chequeno").value=jsonData[a]["chequeno"];
					document.getElementById("baddress").value=jsonData[a]["baddress"];
				}
			
				}
			});
		       });
	 
	 $("#submit").click(function(event) { 
			var req=0;

			 if(document.getElementById('bnameErrorLable').innerHTML!=""){
				req=1;
			}
			 else if(document.getElementById('accnoErrorLable').innerHTML!=""){
					req=1;
				}
			 else if(document.getElementById('ifscErrorLable').innerHTML!=""){
					req=1;
				}
			 if(req==0){		
			var reqUrl="./broker/updateAccount";
			var jsondata = JSON.stringify({"brokerId":$("#brokerId").val(),"bname":$("#bname").val(),"accno":$("#accno").val(),
				"brokage":$("#brokage").val(),"cashl":$("#cashl").val(),"marginl":$("#marginl").val(),"ifsc":$("#ifsc").val(),
				"creditamt":$("#creditamt").val(),"debitamt":$("#debitamt").val(),"billno":$("#billno").val(),"chequeno":$("#chequeno").val(),"baddress":$("#baddress").val()});
		$.ajax(
			  {
			  type: "POST",
			  url: reqUrl,
			  dataType: "json",
			  contentType: 'application/json',	  
			  data:jsondata, 
			  success: function(jsonResponse) { 
				  alert(jsonResponse["msg"]);
				  document.getElementById("brokerId").value="";
				  document.getElementById("ifsc").value="";
				  document.getElementById("bname").value="";
				  document.getElementById("accno").value="";
				  document.getElementById("brokage").value="";
				  document.getElementById("cashl").value="";
				  document.getElementById("marginl").value="";
				  document.getElementById("creditamt").value="";
				  document.getElementById("debitamt").value="";
				  document.getElementById("billno").value="";
				  document.getElementById("chequeno").value="";
				  document.getElementById("baddress").value="";

			  }
			  
			});
			 }
		});
});

function enter()
	{
	location.href = "clientpage.html";
	}
	
function formvalidation(){
	var error	=	false;
	document.getElementById('bnameErrorLable').innerHTML="";
	document.getElementById('accnoErrorLable').innerHTML="";
	document.getElementById('ifscErrorLable').innerHTML="";
		
		 if((document.getElementById('bname').value)==''){
			document.getElementById('bnameErrorLable').innerHTML='*Enter  Bank Name.';
			error	=	true;
		}
		
			if((document.getElementById('accno').value)==''){
			document.getElementById('accnoErrorLable').innerHTML='*Enter Account Name.';
			error	=	true;
		}
			
			if((document.getElementById('ifsc').value)==''){
				document.getElementById('ifscErrorLable').innerHTML='*Enter IFSC Code of your Bank .';
				error	=	true;
			}
			
		if(error==false){
			return true;
			}else{ 
			return false;
		}
}

function isNumberKey(evt){
var charCode = (evt.which) ? evt.which : event.keyCode;
if (charCode > 31 && (charCode < 48 || charCode > 57))
    return false;
return true;
}

</script>
<style>
.reg_form{
width:700px;
height:506px;
background:#fff;
margin:20px 0 0 145px;
float:left;
padding:0px 0 0 0px;
border-radius:10px;
}

.signup{width:96%; float:left; margin:2% 0 0 4%;}

.signup-1{width:94%; float:left; margin-top:15px; margin-bottom:5px; }

.signup-1left{width:189px; float:left; border-radius:5px; height:25px;}

.signup-1middle{width:167px; float:left; border-radius:5px; height:25px; margin-left:21px;}

.signup-1right{width:200px; float:right; border-radius:5px; height:25px;}

textarea, .inputtext, .inputpassword {
    border: 1px solid #BDC7D8;
    margin: 0;
    padding: 3px;
}

.signup-2{margin-top:17px; float:left;}

.signup-3{width:94%; float:left; margin:20px 0px 5px 0px;}

.signup-3left{width:150px; float:left; border-radius:5px; height:25px;}

.signup-3right{width:189px; float:left; border-radius:5px; height:25px; margin-left:174px;}

.signup-3-input{width:296px; float:left; border-radius:5px; height:25px;}

.signup-2-input{width:620px; float:left; border-radius:5px; height:25px;}

.join_5 {
    float: right;
    margin-right: 5px;
    width: 200px;
}

.join_3 {
    float: left;
    margin-bottom: 0px;
    margin-top: 10px;
    width: 306px;
}

.join_4 {
    float: left;
    font-size: 14px;
    margin-left: 5px;
    margin-top: 3px;
    text-align: left;
    width: 90px;
	color:#646262;
	font-weight:600;
}

.signup-4{width:99%; float:left; margin-top:15px;}

.signup-button{float:left; width:500px; margin-top:1%;}
.button{background: linear-gradient(#67AE55, #578843) repeat scroll 0 0 #69A74E; border-color: #3B6E22 #3B6E22 #2C5115; box-shadow: 0 1px 1px #A4E388 inset; padding:8px 0px; float:left; width:150px; border-radius:5px; text-align:center; color:#FFFFFF; font-size:18px; font-weight:bold;}

.text-area{width:94%; float:left; border:1px #CCCCCC solid;}
</style>
</head>
<body>

<div id="main_container">

	<div class="header_login">
    <div class="logo"><a href="#"><img src="img/ncmx-logo.png" alt="" title="" border="0" width="200" height="70"/></a></div>
    
    </div>
    
         <div class="reg_form">
         
         <h3>Manage Broker Account </h3>
         <br/><br/>
         <div class="signup-2">
                   	<select style="border:1px #c2bdbd solid; padding:2px 5px;" id="brokerId"  >
                   	
                   	</select>
                   </div>
         <form id="mngaccount1" method="post" action="./manageacc1">  
         <div class="signup">
         
         
             <div class="signup-3">
                <div class="signup-3left">
        <input name="bname" type="text" value="" maxlength="170" id="bname" required placeholder="Bank Name" class="signup-3-input" data-type="text" style="border:1px #c2bdbd solid; padding:2px 5px;" />
               <div id="bnameErrorLable"></div> </div>
                
                <div class="signup-3right">
       <input name="accno" type="text" value="" maxlength="170" id="accno" required placeholder="Account Number" class="signup-3-input" data-type="text" style="border:1px #c2bdbd solid; padding:2px 5px;" onkeypress="return isNumberKey(event)" />
                 <div id="accnoErrorLable"></div>  </div>
         
      </div>
                   
                 
                  <div class="signup-3">
                <div class="signup-3left">
        <input name="brokage" type="text" value="" maxlength="320" id="brokage" placeholder="Brokage Detail" class="signup-3-input" data-type="text" style="border:1px #c2bdbd solid; padding:2px 5px;" />
               <div id="bnameErrorLable"></div>  </div>
                
                <div class="signup-3right">
       <input name="ifsc" type="text" value="" maxlength="320" id="ifsc" required placeholder="Bank IFSC Code" class="signup-3-input" data-type="text" style="border:1px #c2bdbd solid; padding:2px 5px;"  />
               <div id="ifscErrorLable"></div> </div>
               </div>
            <div class="signup-3">
                 <div class="signup-3left">
                   <input name="cashl" type="text" value="" maxlength="320" id="cashl" placeholder="Cash Limit"  class="signup-3-input" data-type="text" style="border:1px #c2bdbd solid; padding:2px 5px;" onkeypress="return isNumberKey(event)" /></div>
                   
                   <div class="signup-3right">
                   <input name="marginl" type="text" value="" maxlength="320" id="marginl" placeholder="Margin Limit"  class="signup-3-input" data-type="text" style="border:1px #c2bdbd solid; padding:2px 5px;" onkeypress="return isNumberKey(event)"/></div>
              </div>
              
              <div class="signup-3">
                 <div class="signup-3left">
                   <input name="creditamt" type="text" value="" maxlength="320" id="creditamt" placeholder="Credit Amount"  class="signup-3-input" data-type="text" style="border:1px #c2bdbd solid; padding:2px 5px;" onkeypress="return isNumberKey(event)"/></div>
                   
                   <div class="signup-3right">
                   <input name="debitamt" type="text" value="" maxlength="320" id="debitamt" placeholder="Debit Amount"  class="signup-3-input" data-type="text" style="border:1px #c2bdbd solid; padding:2px 5px;" onkeypress="return isNumberKey(event)"/></div>
              </div>
                   
                    <div class="signup-3">
                 <div class="signup-3left">
                   <input name="billno" type="text" value="" maxlength="320" id="billno" placeholder="Bill Number"  class="signup-3-input" data-type="text" style="border:1px #c2bdbd solid; padding:2px 5px;" onkeypress="return isNumberKey(event)"/></div>
                   
                   <div class="signup-3right">
                   <input name="chequeno" type="text" value="" maxlength="320" id="chequeno" placeholder="Cheque Number"  class="signup-3-input" data-type="text" style="border:1px #c2bdbd solid; padding:2px 5px;" onkeypress="return isNumberKey(event)"/></div>
              </div>
                   &nbsp;
                   <br/>
                   <div class="signup-4">
                   	<textarea name="baddress" id="baddress" class="text-area" placeholder="Bank Address" style="border-radius:5px;"></textarea>
                   </div>
                    <br/>
   <div class="signup-button">
           <input class="button" type="button" name="submit" id="submit" value="Update" onclick="formvalidation();"></input>
                   		<!-- <a href="exchangehome"><input class="button" type="button" value="Back" style="margin-left: 100px"></input></a> -->
                    </div>
                        
                        </div>
                        <a class="close" href="#" id="close" style=" right: 290px; top: 126px;"></a>    
                        </form>
         </div>  
          
	
    
    <div class="footer_login">
    
    	<div class="left_footer_login"> <a href="#"></a></div>
    	<div class="right_footer_login"><a href="#"></a></div>
    
    </div>

</div>		
</body>
</html> 